<style type="text/css">
    .chzn-container {
        top:0;
        margin-right: 10px;
        margin-left: 0px;
    }
</style>
<div id="content">
    <div id="page-heading"><h1>Add Question <?php echo isset($survey_id)?"for {$survey['Survey']['title']}":"" ?></h1></div>
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <?php echo $this->Html->image('../images/shared/side_shadowleft.jpg', array('alt' => '', 'width' => '20', 'height' => '300')); ?>
             </th>
            <th class="topleft"></th>
            <td id="tbl-border-top">&nbsp;</td>
            <th class="topright"></th>
            <th rowspan="3" class="sized">
                <?php echo $this->Html->image('../images/shared/side_shadowright.jpg', array('alt' => '', 'width' => '20', 'height' => '300')); ?>
             </th>
        </tr>
        <tr>
            <td id="tbl-border-left"></td>
            <td>
                <div id="content-table-inner">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0">
                        <tr valign="top">
                            <td>
                                <?php echo $this->Form->create("$sN", array('url'=>array('action' => 'add',  isset($survey_id)?$survey_id:""), 'class' => 'form', 'type' => 'file')); ?>
                                <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                                    <?php
                                        echo $this->Session->flash();
                                    ?>
                                    <tr>
                                        <th valign="top">Question:</th>
                                        <td>
                                            <?php
                                                echo $this->Form->input('content', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'type'      =>'textarea',
                                                                    'class'     => 'style-textarea med')
                                                    );     
                                            ?>      
                                        </td>
                                        <td></td> 
                                    </tr>
                                    
                                    <tr>
                                        <th valign="top">Option 1:</th>
                                        <td>
                                            <?php
                                                echo $this->Form->input('option_1', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'onblur'    =>"update_list()",
                                                                    'class'     => 'inp-form med')
                                                    );     
                                            ?>      
                                        </td>
                                        <td></td> 
                                    </tr>
                                    
                                    <tr>
                                        <th valign="top">Option 2:</th>
                                        <td>
                                            <?php
                                                echo $this->Form->input('option_2', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'onblur'    =>"update_list()",
                                                                    'class'     => 'inp-form med')
                                                    );     
                                            ?>      
                                        </td>
                                        <td></td> 
                                    </tr>
                                    
                                    <tr>
                                        <th valign="top">Option 3:</th>
                                        <td>
                                            <?php
                                                echo $this->Form->input('option_3', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'onblur'    =>"update_list()",
                                                                    'class'     => 'inp-form med')
                                                    );     
                                            ?>      
                                        </td>
                                        <td></td> 
                                    </tr>
                                    
                                    <tr>
                                        <th valign="top">Option 4:</th>
                                        <td>
                                            <?php
                                                echo $this->Form->input('option_4', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'onblur'    =>"update_list()",
                                                                    'class'     => 'inp-form med')
                                                    );     
                                            ?>      
                                        </td>
                                        <td></td> 
                                    </tr>
                                    
                                    <tr>
                                        <th valign="top">Option 5:</th>
                                        <td>
                                            <?php
                                                echo $this->Form->input('option_5', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'onblur'    =>"update_list()",
                                                                    'class'     => 'inp-form med')
                                                    );     
                                            ?>      
                                        </td>
                                        <td></td> 
                                    </tr>
                                    
                                    <tr>
                                        <th valign="top">Option 6:</th>
                                        <td>
                                            <?php
                                                echo $this->Form->input('option_6', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'onblur'    =>"update_list()",
                                                                    'class'     => 'inp-form med')
                                                    );     
                                            ?>      
                                        </td>
                                        <td></td> 
                                    </tr>
                                    <tr>
                                        <th valign="top">Answer:</th>
                                        <td>
                                            <script type="text/javascript">
                                                function update_list() {
                                                    $('#answer').html('');
                                                    $('#answer').trigger("liszt:updated");
                                                    for(i=1;i<=6;i++){
                                                        id = "#QuestionOption"+i;
                                                        //console.log($(id).val())
                                                        if($(id).val()!=""){
                                                            $('#answer').append("<option value='option_"+i+"'>Option "+i+"</option>");
                                                        }
                                                    }
                                                    $('#answer').trigger("liszt:updated");
                                                    return false;
                                                };
                                            </script>
                                            <?php
                                                echo $this->Form->input('answer', array(
                                                                    'label'     => false,
                                                                    'div'       => false,
                                                                    'multiple'  =>'multiple',
                                                                    "id"        =>'answer',
                                                                    'type'      =>'select',
                                                                    'empty'     =>'',
                                                                    'data-placeholder'=>'Select one or more option',
                                                                    //'options'   =>array('option_1'=>'Option 1','option_2'=>'Option 2','option_3'=>'Option 3','option_4'=>'Option 4','option_5'=>'Option 5','option_6'=>'Option 6'),
                                                                    'class'     => 'chosen med')
                                                    );     
                                            ?>    
                                        </td>
                                        <td>If you select more than one option , the type of question will be multiselect and if not , it is oneselect</td> 
                                    </tr>
                                    
                                    <tr>
                                        <th>&nbsp;</th>
                                        <td valign="top">
                                            <?php echo $this->Form->submit('Save', array('value'=>"save",'div'=>false,'class' => 'submit-button')); ?>
                                            <?php echo $this->Form->submit('Save and add more', array('value'=>'add_more','div'=>false,'class' => 'submit-button')); ?>
                                            <?php echo $this->Html->link('Cancel', array('controller' => $lN, 'action' => 'index', 'admin' => true), array('class' => 'cancel-button')); ?>
                                            <?php echo $this->Form->hidden('submit', array('id' => 'sbmtValue', 'value' => '')); ?>
                                            <script type="text/javascript">
                                                $(document).ready(function(){
                                                    $('.submit-button').click(function(){
                                                       $('#sbmtValue').val($(this).val());
                                                    });
                                                });
                                            </script>
                                        </td>
                                        <td></td>
                                    </tr>
                                </table>       
                                <?php echo $this->Form->end();?>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>
                               <?php echo $this->Html->image('../images/shared/blank.gif', array('alt' => 'blank', 'width' => '695', 'height' => '1')); ?>
                            </td>
                            <td></td>
                        </tr>
                    </table>
                    <div class="clear"></div>
                </div>
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
            <th class="sized bottomleft"></th>
            <td id="tbl-border-bottom">&nbsp;</td>
            <th class="sized bottomright"></th>
        </tr>
    </table>
    <div class="clear">&nbsp;</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function(){
            jQuery("#surveyMenu").addClass('current');
});
</script>